home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PBLIB1 / PROGS / FIND.PAS < prev    next >
Pascal/Delphi Source File  |  1994-05-03  |  3KB  |  136 lines

  1. (*PAGE*)
  2. PROGRAM FIND;
  3.  
  4. {$M 20000,0,655000}
  5.  
  6. Uses DOS, PbMISC, PbDATA, PbOBJS, PbOUT0, PbPARMS;
  7.  
  8. {
  9. Description : FIND - locates all occurances of a filespec
  10.  
  11. Author      : Howard Richoux
  12. Date        : 12/9/93
  13. Last revised: 12/21/93 1.05 minor fixes
  14.               12/30/93 1.10 combined with BIGFILES
  15.                2/18/94 1.12 NEW LIBRARIES
  16. Application : IBM PC and compatibles, done in Turbo Pascal 7.0
  17. Status      : Placed in the Public Domain by HNR Software 1/29/94
  18. Published in: none
  19.  
  20. combined program BIGFILES and FIND to save code
  21.  
  22. >FIND *.* MODE=BIG MINSIZEK=250                    (SEARCHES WHOLE DISK)
  23. >FIND *.* MODE=BIG MINSIZEK=250  ROOT=C:\WINDOWS   (SEARCHES C:\WINDOWS\..)
  24.  
  25. >FIND MISCSTUF.PAS
  26.  
  27.  
  28. }
  29.  
  30.  
  31.  
  32. var filespec : string;
  33. var ProgramMode : string;
  34. var err      : byte;
  35. var minsizek : longint;
  36. var minsize  : longint;
  37. var outfile  : string;
  38. var root     : string;
  39. var count    : integer;
  40.  
  41.  
  42.  
  43. {*****************************************************************}
  44.  
  45. {
  46.  SearchRec - for reference
  47.     type searchrec = record
  48.            fill  : array[1..21] of byte;
  49.            attr  : byte;
  50.            time  : longint;
  51.            size  : longint;
  52.            name  : string[12];
  53.            end;
  54. }
  55.  
  56.  
  57. { FIND portion }
  58.  
  59. Procedure DealWithFind( var sr : SearchRec; p : pathstr);
  60. var s : string;
  61.      begin
  62.      OUT(FullFmtSearchRec(SR,p));
  63.      end;
  64.  
  65.  
  66. Procedure FindIt;
  67.      begin
  68.      filespec := paramstr(1);
  69.    {  SearchEngineAll('c:\',filespec,anyfile,DealWithfind,Err);}
  70.      SearchEngineAll(root,filespec,anyfile,DealWithfind,Err);
  71.      end;
  72.  
  73.  
  74.  
  75. {BIGFILES portion }
  76.  
  77. Procedure DealWithBigFile( var sr : SearchRec; p : pathstr);
  78. var s : string;
  79.      begin
  80.      if sr.size > minsize then
  81.           begin
  82.           if count = 0 then
  83.                begin
  84.                OUT('  Current threshold ='+integerstr(minsizek,4)+
  85.                      'k   root dir='+root);
  86.                OUT(' ');
  87.                end;
  88.           OUT(FullFmtSearchRecK(sr,p));
  89.           inc(count);
  90.           end;
  91.      end;
  92.  
  93.  
  94. Procedure CheckBiggies;
  95.      begin
  96.      writeln('  Current threshold =',minsizek,'k   root dir=',root,
  97.             '  Out=',pOutFile);
  98.      SearchEngineAll(root,'*.*',anyfile,DealWithBigFile,Err);
  99.      if count = 0 then writeln('   No files found.')
  100.      else OUT('   Files found: '+ integerstr(count,4));
  101.      end;
  102.  
  103.  
  104. {Initialization}
  105.  
  106. Procedure init;
  107.      begin
  108.      AddParm(1,'ROOT','');            {default to current path}
  109.      AddParm(1,'MINSIZEK','100');     {100k byte minimum}
  110.      AddParm(1,'MODE','FIND');        {FIND/BIG}
  111.  
  112.      StandardOUTInit;
  113.  
  114.      ProgramMode := UpCaseStr(GetPARMStr('MODE'));
  115.  
  116.      count    := 0;
  117.      minsizek := GetParmNum('MINSIZEK');
  118.      minsize  := minsizek * 1024;
  119.      root     := GetParmStr('ROOT');
  120.      if root='*.*' then GetDir(0,root);
  121.      end;
  122.  
  123.  
  124. (*  Main program *)
  125.      BEGIN
  126.      pProgID := 'Find 1.12';
  127.      init;
  128.      if (ParamCount > 0) then
  129.           begin
  130.           if ProgramMode = 'FIND' then FindIt
  131.           else CheckBiggies;
  132.           end
  133.      else ShowDocFile;
  134.      OUTdone;
  135.      end.
  136.